<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#">商户管理</a></li>
		</ul>
        <form class="well form-search" method="post" action="{:U('Business/index')}">
            商户名:
            <input type="text" name="name" style="width: 100px;" value="{:I('request.name/s','')}" placeholder="请输入商户名">
            公司名:
            <input type="text" name="company" style="width: 100px;" value="{:I('request.company/s','')}" placeholder="请输入公司名">
            商户类型:
            <php>$type=I('type');</php>
            <select name="type" style="width: 100px;" >
                <option value="0">全部</option>
                <option value="1" <php>if($type==1){echo 'selected';}</php> >商户</option>
                <option value="2" <php>if($type==2){echo 'selected';}</php> >技师</option>
            </select>
            经营范围:
            <php>$scope_id=I('scope_id');</php>
            <select name="scope_id" style="width: 100px;" >
                <option value="0">全部</option>
                <foreach name="scopes" item="scope">
                    <option value="{$scope.id}" <php>if($scope_id==$scope['id']){echo 'selected';}</php> >{$scope.name}</option>
                </foreach>
            </select>
			是否推广:
			<php>$is_prepared=I('is_prepared');</php>
			<select name="is_prepared" style="width: 100px;" >
				<option value="99">全部</option>
				<option value="0" <php>if($is_prepared==="0"){echo 'selected';}</php> >推广商户</option>
				<option value="1" <php>if($is_prepared==1){echo 'selected';}</php> >正常商户</option>
			</select>
			<br/>
			<br/>
			城市(请选择到区域级别)：
			<select id="s_province">
				<option value="0">请选择省份</option>
				<foreach name="provinces" item="province">
					<option value="{$province.id}">{$province.name}</option>
				</foreach>
			</select>
			<select id="s_city" style="display: none">
				<option value="0">请选择城市</option>
			</select>
			<select id="s_district" name="region_id" style="display: none">
				<option value="0">请选择区域</option>
			</select>
            <input type="submit" class="btn btn-primary" value="搜索" id="sou"/>
            <a class="btn btn-danger" href="{:U('Business/index')}">清空</a>
        </form>
		<php>$status=array("0"=>'禁用',"1"=>'正常',"2"=>'未验证手机','3'=>'未选择类型','4'=>'未传资质','5'=>'未装修');</php>
		<php>$type=array("1"=>'商户',"2"=>'技师');</php>
		<php>$qualify_type=array("1"=>'标准',"2"=>'小商户');</php>
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">ID</th>
						<th>商户名</th>
						<th>公司名</th>
						<th>类型</th>
						<th>经营范围</th>
						<th>收藏数</th>
						<th>访问量</th>
						<th>评分</th>
						<th>资质</th>
						<th>电话</th>
						<th>注册时间</th>
						<th>推广</th>
						<th>url</th>
						<th width="45">{:L('STATUS')}</th>
						<th width="120">{:L('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<foreach name="businesses" item="vo">
					<tr>
						<td>{$vo.id}</td>
						<td>{$vo.name}</td>
						<td>{$vo.company}</td>
                        <td>{$type[$vo['type']]}</td>
						<td>{$vo.sname}</td>
						<td>{$vo.collect_num}</td>
						<td>{$vo.visit_num}</td>
						<td>{$vo.points}</td>
						<td>{$qualify_type[$vo['qualify_type']]}</td>
						<td>{$vo.phone}</td>
						<td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
						<td>{$vo.url}</td>
						<td><php>if($vo['is_prepared']==1){echo '否';}else{echo '是';}</php></td>
						<td>{$status[$vo['status']]}</td>
						<td>
                            <a href="{:U('Business/getDetails',array('id'=>$vo['id']))}">查看详情</a> |
                            <a href="{:U('Business/changeQualify',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定改变资质么？">改变资质</a> |
                            <a href="{:U('Business/ban',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定禁用么？">禁用</a> |
                            <a href="{:U('Business/cancelban',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定启用么？">启用</a> |
                            <a href="javascript:;" class="addOrderNumber" service_id="{$vo['id']}" web_url="{$vo.url}">修改资料</a>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
		</form>
		<div class="pagination">{$page}</div>
	</div>
    <div style="width: 489px;height:287px;text-align: center;position: absolute;margin-left: 50%;left: -240px;margin-top:50%;top:0px;display: none;z-index:9;border: 1px solid #fff" id="banDiv">
        <div style="height: 40px;background: #f7f8fa;padding-top: 15px;text-align: left;padding-left: 22px">密码<button type="button" style="border:none;width: 14px;background: #f7f8fa;color: #ccc;padding-left: 400px" id="hideBan">X</button></div>
        <div style="background: #fff;text-align: center;height: 210px;padding-top:33px">
            <div style="width: 200px;text-align: right;color: #666666">请输入密码，不改留空</div>
            <br>
            <input type="text" id="ban_number">
            <br>
            <div style="width: 200px;text-align: right;color: #666666">请输入url</div>
            <br>
            <input type="text" id="ban_number2">
            <br>
            <button type="button" style="border:none;width: 215px;height: 30px;background: #19c571;color: #fff" id="ban">重置</button>
        </div>
    </div>
	<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>
<script>
    $('.addOrderNumber').click(function(r){
        var top=$(document).scrollTop();
        var height=$(window).height();
        height=parseInt(height)-132;
        top=-(height-parseInt(top));
        $('#banDiv').css('top',top);
        service_id=$(this).attr('service_id');
        var web_url=$(this).attr('web_url');
        $('#ban_number2').val(web_url);
        $('#banDiv').show();
        $('#banZhe').show();
    });
    $('#hideBan').click(function(r){
        service_id=0;
        $('#banDiv').hide();
        $('#banZhe').hide();
    });
    $('#ban').click(function(r){
        var number=$('#ban_number').val();
        var web_url=$('#ban_number2').val();
        $.post('{:U("Business/resetPassword")}',{id:service_id,password:number,web_url:web_url},function(r){
            alert(r.info);
            /*            if(r.status==1){
             window.location.href="{:U('Business/checkBusinesses')}"
             }*/
            window.location.href = location.pathname + location.search;
        });
    });
</script>